//
//  MyLeave.m
//  SchoolTask
//
//  Created by feel on 16/8/26.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "MyLeave.h"
#define kScreenW [UIScreen mainScreen].bounds.size.width
#define kScreenH [UIScreen mainScreen].bounds.size.height

@interface MyLeave ()

@property (nonatomic,retain) UIView   *reasonView;         //请假类型
@property (nonatomic,retain) UILabel  *reasonLb;           //展示请假类型
@property (nonatomic,retain) UIButton *selectReason;       //选择请假类型按钮

@property (nonatomic,retain) UIView   *timeInfoView;       //起止和结束日期
@property (nonatomic,retain) UILabel  *startForDate;       //起始日期展示
@property (nonatomic,retain) UIButton *seletData;          //选择时间按钮
@property (nonatomic,retain) UILabel  *startForTime;       //开始时间展示
@property (nonatomic,retain) UIButton *seletctTime;        //选择时间按钮
@property (nonatomic,retain) UILabel  *endForDate;         //结束日期展示
@property (nonatomic,retain) UIButton *endSeletData;       //结束时间按钮
@property (nonatomic,retain) UILabel  *endForTime;         //结束时间展示
@property (nonatomic,retain) UIButton *endSeletctTime;     //结束时间按钮

@property (nonatomic,retain) UIView   *dateNumView;        //请假时间
@property (nonatomic,retain) UITextField *date;            //请假天数

@property (nonatomic,retain) UIView   *reasonInfoView;     //原因详情
@property (nonatomic,retain) UITextView *reasonInfo;       //请假原因详情

@property (nonatomic,retain) UIView   *imageView;          //图片

@property (nonatomic,retain) UIView   *instructionsView;   //批示
@property (nonatomic,retain) UILabel  *teacher;            //老师批示展示
@property (nonatomic,retain) UILabel  *classMonitor;       //班长批示展示

@property (nonatomic,retain) UIButton *commitBt;             //提交按钮

@end

@implementation MyLeave

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [UIColor colorWithRed:230/255.0 green:235/255.0 blue:235/255.0 alpha:1];
        [self setViewAndController];
    }
    return self;
}

- (void)setViewAndController {
    
    CGFloat h = 736 / kScreenH;
    CGFloat w = 414 / kScreenW;
    
    _reasonView      = [[UIView alloc]initWithFrame:CGRectMake(0, 70/h, kScreenW, 50/h)];
    _timeInfoView    = [[UIView alloc]initWithFrame:CGRectMake(0, 130/h, kScreenW, 100/h)];
    _dateNumView     = [[UIView alloc]initWithFrame:CGRectMake(0, 240/h, kScreenW, 50/h)];
    _reasonInfoView  = [[UIView alloc]initWithFrame:CGRectMake(0, 300/h, kScreenW, 150/h)];
    _imageView       = [[UIView alloc]initWithFrame:CGRectMake(0, 460/h, kScreenW, 50/h)];
    _instructionsView = [[UIView alloc]initWithFrame:CGRectMake(0, 520/h, kScreenW, 150/h)];
    
    //_reasonView控件配置
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 15/h, 150/w, 30/h)];
    label.text = @"请假类型";
    label.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];

    _reasonLb = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 110/h, 10/w, 70/h, 30/w)];
    _reasonLb.text = @"事假";
    _reasonLb.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];

    _selectReason = [UIButton buttonWithType:UIButtonTypeCustom];
    _selectReason.frame = CGRectMake(kScreenW - 40/h, 10/w, 30/h, 30/w);
    [_selectReason setBackgroundImage:[UIImage imageNamed:@"下拉按钮图标"] forState:UIControlStateNormal];
    [_selectReason addTarget:self action:@selector(reasonAction) forControlEvents:UIControlEventTouchUpInside];
    [_reasonView addSubview:_reasonLb];
    [_reasonView addSubview:_selectReason];
    [_reasonView addSubview:label];

//_timeInfoView
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, 50/h, kScreenW, 1)];
    line.backgroundColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    
    //开始时间的相关配置
    UILabel *start = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 10/h, 100/w, 30/h)];
    UILabel *end   = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 60/h, 100/w, 30/h)];
    _startForDate  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 200/w, 10/h, 80/w, 30/h)];
    _seletData     = [UIButton buttonWithType:UIButtonTypeCustom];
    _seletData.frame = CGRectMake(kScreenW - 120/w, 10/h, 20/w, 30/h);
    
    _startForTime  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 100/w, 10/h, 70/w, 30/h)];
    _seletctTime     = [UIButton buttonWithType:UIButtonTypeCustom];
    _seletctTime.frame = CGRectMake(kScreenW - 30/w, 10/h, 20/w, 30/h);

    _startForDate.text = @"2016.12.18";
    _startForTime.text = @"12:30";
    _startForDate.font = [UIFont systemFontOfSize:15/w];
    _startForTime.font = [UIFont systemFontOfSize:15/w];
    _startForDate.textAlignment = 2;
    _startForTime.textAlignment = 2;
    
    [_seletctTime setBackgroundImage:[UIImage imageNamed:@"下拉按钮图标"] forState:UIControlStateNormal];
    [_seletData setBackgroundImage:[UIImage imageNamed:@"下拉按钮图标"] forState:UIControlStateNormal];

    start.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    end.textColor   = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    _startForDate.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    _startForTime.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    
    //结束栏相关控件配置
    _endForDate  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 200/w, 60/h, 80/w, 30/h)];
    _endSeletData     = [UIButton buttonWithType:UIButtonTypeCustom];
    _endSeletData.frame = CGRectMake(kScreenW - 120/w, 60/h, 20/w, 30/h);
    
    _endForTime  = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW - 100/w, 60/h, 70/w, 30/h)];
    _endSeletctTime     = [UIButton buttonWithType:UIButtonTypeCustom];
    _endSeletctTime.frame = CGRectMake(kScreenW - 30/w, 60/h, 20/w, 30/h);
    
    _endForDate.text = @"2016.12.18";
    _endForTime.text = @"12:30";
    _endForDate.font = [UIFont systemFontOfSize:15/w];
    _endForTime.font = [UIFont systemFontOfSize:15/w];
    _endForDate.textAlignment = 2;
    _endForTime.textAlignment = 2;
    
    [_endSeletctTime setBackgroundImage:[UIImage imageNamed:@"下拉按钮图标"] forState:UIControlStateNormal];
    [_endSeletData setBackgroundImage:[UIImage imageNamed:@"下拉按钮图标"] forState:UIControlStateNormal];

    _endForDate.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    _endForTime.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];

    
    [_timeInfoView addSubview:_startForTime];
    [_timeInfoView addSubview:_seletData];
    [_timeInfoView addSubview:_startForDate];
    [_timeInfoView addSubview:_seletctTime];
    [_timeInfoView addSubview:start];
    [_timeInfoView addSubview:end];
    [_timeInfoView addSubview:line];
    [_timeInfoView addSubview:_endForDate];
    [_timeInfoView addSubview:_endForTime];
    [_timeInfoView addSubview:_endSeletData];
    [_timeInfoView addSubview:_endSeletctTime];

    start.text = @"开始时间";
    end.text = @"结束时间";

//请假天数 dateNumView
    UILabel *dateForNum = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 10/h, 100/w, 30/h)];
    dateForNum.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    dateForNum.text = @"请假天数";
    _date = [[UITextField alloc]initWithFrame:CGRectMake(150/w, 10/h, 150/w, 30/h)];
    _date.placeholder = @"请输入请假天数";
    _date.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];

    [_dateNumView addSubview:dateForNum];
    [_dateNumView addSubview:_date];
//请假具体原因 reasonInfoView
    UILabel *reason = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 10/h, 100/w, 30/h)];
    reason.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    reason.text = @"请假事由";
    _reasonInfo = [[UITextView alloc]initWithFrame:CGRectMake(130/w, 10/h, 200/w, 100/h)];
    _reasonInfo.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    //设置文本框的滚动和边框
    _reasonInfo.scrollEnabled = YES;
    _reasonInfo.layer.borderColor = [[UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1] CGColor];
    _reasonInfo.layer.shouldRasterize = YES;
    _reasonInfo.layer.borderWidth  = 1;
    _reasonInfo.layer.cornerRadius = 5;
    [_reasonInfoView addSubview:reason];
    [_reasonInfoView addSubview:_reasonInfo];
    
//图片 imageView
    UILabel *imageLb = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 10/h, 100/w, 30/h)];
    imageLb.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    imageLb.text = @"图片";
    
    [_imageView addSubview:imageLb];

//instructionsView
    UILabel *instructionsLb = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 10/h, 100/w, 30/h)];
    instructionsLb.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    instructionsLb.text = @"审批人";
    
    UILabel *counselor = [[UILabel alloc]initWithFrame:CGRectMake(20/w, 50/h, 80/w, 30/h)];
    counselor.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    counselor.text = @"辅导员:";
    
    UILabel * classMonitor = [[UILabel alloc]initWithFrame:CGRectMake(200/w, 50/h, 100/w, 30/h)];
    classMonitor.textColor = [UIColor colorWithRed:100/255.0 green:100/255.0 blue:100/255.0 alpha:1];
    classMonitor.text = @"班长:";
    [_instructionsView addSubview:instructionsLb];
    [_instructionsView addSubview:counselor];
    [_instructionsView addSubview:classMonitor];
    
    //提交按钮配置
    _commitBt = [UIButton buttonWithType:UIButtonTypeCustom];
    _commitBt.frame = CGRectMake(0, 675/h, kScreenW, 50/h);
    [_commitBt setTitle:@"提交" forState:UIControlStateNormal];
    _commitBt.tintColor = [UIColor whiteColor];
    _commitBt.backgroundColor = [UIColor colorWithRed:250/255.0 green:140/255.0 blue:0/255.0 alpha:1];

    _reasonView.backgroundColor   = [UIColor whiteColor];
    _timeInfoView.backgroundColor = [UIColor whiteColor];
    _dateNumView.backgroundColor  = [UIColor whiteColor];
    _imageView.backgroundColor    = [UIColor whiteColor];
    _instructionsView.backgroundColor = [UIColor whiteColor];
    _reasonInfoView.backgroundColor   = [UIColor whiteColor];
    
    [self addSubview:_reasonView];
    [self addSubview:_timeInfoView];
    [self addSubview:_dateNumView];
    [self addSubview:_reasonInfoView];
    [self addSubview:_imageView];
    [self addSubview:_instructionsView];
    [self addSubview:_commitBt];
}

- (void)reasonAction {
    
    NSLog(@"选择请假类型");
}


@end
